// index.js
// const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
// import { getJob } from '../../api/index.js'
const _function = require("../../utils/functionData.js")
Page({
  data: {
    jobList: [],
    teaList: [],
    role: getApp().globalData.userInfo.role,
    _UrlGet_: wx.getStorageSync('img_url'),
    seaType: 0,
    searchValue: ''
  },
  goCareerList() {
    console.log(123)
    wx.navigateTo({
      url: '/pages/careerlist/careerlist?searchValue=' + this.data.searchValue,
    })
  },
  goMentorList() {
    wx.navigateTo({
      url: '/pages/mentorlist/mentorlist?searchValue=' + this.data.searchValue,
    })
  },
  goCareerAss() {
    wx.navigateTo({
      url: '/pages/careerassessment/careerassessment',
    })
  },
  // 表单字段更新 
  onFieldChange(e) {
    const value = e.detail.value
    console.log('value', value);
    this.setData({
      seaType: value
    })
  },
  onSeaChange(e) {
    const value = e.detail.value
    console.log('value', value);
    this.setData({
      searchValue: value
    })
  },
  goSearch() {
    console.log('this.data.seaType', this.data.seaType);
    if (this.data.seaType == 0) {
      this.goCareerList()
    } else {
      this.goMentorList()
    }
  },
  onShow() {
    this.setData({
      searchValue: '',
      seaType:0
    })
    if (typeof this.getTabBar === 'function' && this.getTabBar()) {
      this.getTabBar().setData({
        selected: 0  //这个数字是当前页面在tabBar中list数组的索引
      })
    }


  },
  onLoad() {
   
    this.getHotJob()
    this.getHotTeacher()
  },

  // 请求订单列表
  getHotJob() {
    _function.getHotJob(this.data.param, this.getHotJobBack, this)
  },
  getHotJobBack(res) {
    let dataAll = res.data
    if (dataAll.code == 200) {
      this.setData({
        jobList: dataAll.data
      })
    }
  },
  getHotTeacher() {

    _function.getHotTeacher(this.data.param, this.getHotTeacherBack, this)
  },
  getHotTeacherBack(res) {
    let dataAll = res.data
    if (dataAll.code == 200) {
      console.log('热门导师', dataAll.data);
      this.setData({
        teaList: dataAll.data
      })
    }
  }

})
